﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Net;
using System.Net.Mail;
using System.Text;
using ORS.DAL;
using System.Data;

namespace ORS.BLL
{
    public class Emailsend
    {



        /// <summary>

        /// 构造一个邮件通知服务类的实例。

        /// </summary>

        /// <param name="smtpService">SMTP服务器的IP地址</param>

        /// <param name="enableSSL">是否使用SSL连接SMTP服务器器</param>

        /// <param name="port">SMTP服务器端口</param>

        /// <param name="loginName">用于登录SMTP服务器的用户名</param>

        /// <param name="password">登录密码</param>


        private string m_smtpService = "smtp.163.com";

        private string m_loginName = "hopeprj@163.com";

        private string m_password = "Group18";

        private bool m_enableSSL = false;

        private int m_port = 25;



        /// <summary>

        /// 发送邮件通知到指定的EMAIL地址。

        /// </summary>

        /// <param name="senderName">显示在“发件人”一栏上的名称</param>

        /// <param name="address">目的EMAIL地址</param>

        /// <param name="title">邮件标题</param>

        /// <param name="content">邮件内容</param>

        public void SendTo(string address, string title, string content)
        {



            MailMessage mail = new MailMessage();

            mail.To.Add(address);

            mail.From = new MailAddress(this.m_loginName, "ORS在线审稿提示", Encoding.UTF8);

            mail.Subject = title;

            mail.Body = content;

            mail.BodyEncoding = Encoding.UTF8;

            mail.IsBodyHtml = false;

            mail.Priority = MailPriority.Normal;



            SmtpClient smtp = new SmtpClient();

            smtp.Credentials = new NetworkCredential(this.m_loginName, this.m_password);

            smtp.Host = this.m_smtpService;

            smtp.EnableSsl = this.m_enableSSL;

            smtp.Port = this.m_port;



            smtp.Send(mail);

        }
        public String getEmailAd(string userID) 
        {
            DataTable dt = new DataTable();
            String sqlstr1 = "SELECT email FROM tb_userlist WHERE userid='" + userID + "'";
            mssqlopr ivk_mssqlopr = new mssqlopr();
            dt = ivk_mssqlopr.GetDataTable(sqlstr1);
            return dt.Rows[0]["email"].ToString();
        }

    }

}